System And Method For Real-Time Image Retensioning And Loop Error Correction

ABSTRACT

Due to an accumulated error from the pair-wise registration, the stitched image may be blurred or have a gap when a loop is encountered. In order to remove the accumulated error, we identify a closed loop where a first image frame overlaps with a second image frame, the second image frame being captured earlier in a scanning sequence than the first image frame; register the first image frame with the second image frame; and apply a global optimization to adjust registration parameters for the plurality of pair-wise registrations of image frames within the closed loop using global constraints.

CROSS-REFERENCE TO RELATED APPLICATIONS

Commonly owned U.S. patent application Ser. No. 12/648,236, filed Dec. 28, 2009, Publication No. 2010/0171996, and U.S. patent application Ser. No. 12/645,421, filed Dec. 22, 2009, Publication No. 2010/0165422 are hereby incorporated by reference in their entirety. This application is also related to commonly owned U.S. patent application Ser. No. ______, filed ______, entitled “Image registration parameters and confidence estimation from sensor data” (Attorney Docket No. EETP130) and U.S. patent application Ser. No. ______, filed ______, entitled “System and method for integrated pair-wise registration of images using image based information and sensor coordinate and error information” (Attorney Docket No. EETP132), the contents of such applications being hereby incorporated by reference in their entirety.

BACKGROUND

1. Field of Invention

The present invention is related to scanning devices, particularly document scanners of the hand-held type, such as a mouse scanner.

2. Description of Related Art

A variety of document scanning devices exist in the art. They include fax machines, copiers, multifunction fax/copy/print devices, stand-alone flat-bed scanners and the like. A disadvantage to these types of devices is that they are large and not portable. So, the document to be scanned must be brought to them. Recently, small hand-held scanners have been introduced. Some are portable and stand-alone such as the VuPoint PDS-ST410-VP Magic Wand Portable Scanner. Others can be connected to a laptop computer such as the Xerox Travel Scanner 100. These types of scanners, however, are still large enough to accept a sheet of paper.

A more recent development is a very small scanner that scans only a portion of the document (e.g. a page of a book or a photo) as the scanning device is moved over the document. Image processing is used to stitch together these scanned portions to create a copy of the entire page or entire photo. U.S. published patent application no. US 2010/0124384 describes one example of this type of device. In some cases the devices operate in two modes; in one mode they operate as a conventional mouse and in another mode they operate as a scanner. Commonly owned U.S. patent application Ser. No. 12/648,236, filed Dec. 28, 2009, Publication No. 2010/0171996, and U.S. patent application Ser. No. 12/645,421, filed Dec. 22, 2009, Publication No. 2010/0165422, describe this type of device, sometimes referred to as a “mouse scanner.”

Some of the problems encountered in these types of small scanners that are moved by hand over a document are poor image quality and poor registration of the multiple scanned portions.

SUMMARY OF INVENTION

When scanning a document as a sequence of image frames, e.g. moving a scanner or other image capturing device across a document from left to right, and then down, and then right to left, for example, each frame will usually overlap with a frame to its right and/or left and a frame above and/or below it. If we go back to a frame captured earlier in the sequence, a “close-the-loop condition” is detected if we can align the current frame with this prior captured frame, which may be part of the image above or below the current frame, for example.

A pair-wise registration is a registration between one frame and the next captured frame in the sequence. When the sequence of images are stitched together to form a composite image of the document, each pair wise registration, though successful on its own, accumulates some error. This small error, which may be just a few pixels, is not noticeable when one image frame is registered with the image frame that is next in the scanning sequence. However, this error accumulates as more and more images are stitched together. When an image that comes later in the sequence of images overlaps an image that is much earlier in the sequence, this error can become visible and create breaks and mismatches in the stitched images. The present invention reduces and corrects the accumulated error by optimizing a number of pair-wise registrations of images with global constraints. The global constraints close the loop, thus negating any visible differences between new images that overlap older images.

Due to an accumulated error from the pair-wise registration, the stitched image may be blurred or have a gap when a loop is encountered. In order to remove the accumulated error, we correct the loop by global optimization of all pair-wise registrations in a loop which will minimize not only pair-wise registration errors but also the global registration errors with the close-loop constraints so that the accumulated error is minimized after backward error correction.

The error function takes the global constraints (close the loop constraints) into the error vector so that it can minimize the accumulated errors as well as the pair-wise registration errors.

Other objects and attainments together with a fuller understanding of the invention will become apparent and appreciated by referring to the following description and claims taken in conjunction with the accompanying drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

In the drawings wherein like reference symbols refer to like parts.

FIG. 1 is a schematic view of the mouse scanner 10 of the present invention.

FIG. 2 is a system block diagram of the present invention.

FIG. 3 is a flow diagram of the overall process of the present invention.

FIG. 4 illustrates a pixel quad in a Bayer mosaic.

FIG. 5 illustrates interpolation options for dewarping in the present invention.

FIG. 6 is a flow diagram illustrating the general process for estimating transformation parameters in the present invention.

FIG. 7 illustrates the relationship of two frames, frame i and frame i+1, disposed to one another at an angle θ in a common x-y coordinate space.

FIG. 8 illustrates two frames that were scanned with mouse scanner 10 with their positions recorded by laser sensors 22.

FIG. 9 illustrates the overlap area between the two frames shown in FIG. 8.

FIG. 10 is a flowchart generally showing registration of two images where downsampled images are registered in a low resolution when sensor confidence is low.

FIG. 11 illustrates a registration loop in which there is a registration break between a frame and the previous frame.

FIG. 12 illustrates a close-the-loop correction of the break shown in FIG. 11 by registering the frame to an earlier frame that is before the previous frame.

FIG. 13 illustrates a case in which a new loop contains one or more closed loops.

FIG. 14 illustrates extraction of the new loop shown in FIG. 13 from frames 1 to N.

FIG. 15 illustrates a case in which a new loop is inside a closed loop, which has been corrected.

FIG. 16 illustrates the extraction of frames from K to N for the new loop shown in FIG. 15, where frames K to L are corrected.

FIG. 17 illustrates extraction of the new loop shown in FIG. 16 from frames 1 to N.

FIG. 18 is a flowchart generally outlining the steps of loop correction.

DESCRIPTION OF THE PREFERRED EMBODIMENTS

FIGS. 1 and 2 are schematic views of the mouse scanner 10 and system of the present invention. The housing 12 is preferably shaped like a typical computer mouse. Inside the housing 12 is a camera 14. Preferably camera 14 is a CMOS sensor type that is especially suited for digital imaging. However, other types of devices for digitizing a scanned area, such as CCD (charge coupled device) type image capturing device, can be used. The image capture portion of mouse scanner 10 may also include LEDs positioned to illuminate the portion of a document that is underneath mouse scanner 10 as it is moved over the document. LEDs are the preferable light source but other types such as incandescent or fluorescent could be considered possible alternatives depending on the size and configuration of mouse scanner 10. To enhance or improve illumination, light reflecting mirrors may also be provided. The image is captured through scanning window 28 formed in the bottom of the mouse scanner housing 12.

Although the present invention is described herein with reference to a particular device, i.e. a mouse scanner, for ease of understanding. It is to be understood that aspects of the present invention apply to other devices that acquire input data such as digital cameras, video cameras, scanners, and other sensing devices such as X-ray machines or MRI machines. Also, the term “image” similarly applies to the input data acquired by such devices.

Once a scan button is pressed by an operator, the mouse scanner 10 is moved across the document, with the position of mouse scanner 10 indicated by four laser motion sensors 22. A scan button is just one option to control the scanning process, which could also be automatically controlled. These laser motion sensors 22 are located on the bottom of mouse scanner 10 and shown as sensors S1, S2, S3, and S4 in FIG. 1. These laser motion sensors 22 provide position indicating data that represent the relative position of one captured image (a frame) to another. Each captured frame can also be thought of a “tile.” The frames or tiles are stitched together based, at least initially, upon their relative positions as indicated by the laser motion sensors 22. A composite image is formed (refined) using image processing, which, for example measures the correspondence between adjacent stitched images that form the composite. Laser motion sensors are preferably used for position sensing but alternative position sensors could include speed, acceleration, and/or gyroscopic sensors.

Mouse scanner 10 also includes an FPC (flexible printed circuit) main board 24. Main board 24 controls the activity and processing in mouse scanner 10 and communicates with an external PC via, for example, a USB connector port. FIG. 2 is a schematic representation of main board 24 and its connection to an external PC (host computer). Main board 24 exchanges data with a host computer 250 (PC) by way of an intervening interface 202. Application programs and an image capture device driver may also be stored for access on the host computer 250. The driver can receive and interpret various signals and data from main board 24, and provide necessary information to the user by way of the host computer 250.

When data is sent by the host computer 250, the interface 202 receives the data and stores it in a receive buffer forming part of a RAM 204. The RAM 204 can be divided into a number of sections, for example through addressing, and allocated as different buffers, such as a receive buffer or a send buffer. Data, such as digital image data, can also be obtained by camera 14, the flash EEPROM 210, or the ROM 208. For example, the camera 14 can generate a digital image by scanning a portion of a document, such as a page of a book or a photo. This digital image can then be stored in the receive buffer or the send buffer of the RAM 204.

A processor 206 uses computer-executable instructions stored on a ROM 208 or on a flash EEPROM 210, for example, to perform a certain function or group of functions, such as the methods of the present invention. Where the data in the receive buffer of the RAM 204 is a digital image, for example, the processor 206 (or more likely one or more processors in computer 250) can implement the methodological acts of the present invention on the digital image to, for example, stitch the digital image with other digital images based upon their position information and feature correspondence to create a composite image representing a whole page or photo. Further processing in an imaging pipeline may then be performed on the digital image before the image is transferred to the host computer 250 for additional processing, for printing on printer 262, projected with projector 264, or stored on hard disk 260, for example.

The methods of the present invention and variations thereof disclosed herein can be implemented using tangible, non-transitory computer-readable media for carrying or having computer-executable instructions or data structures stored thereon. Such computer-readable media can be any available media that can be accessed by a processor of a general purpose or special purpose computer. By way of example, and not limitation, such computer-readable media can comprise RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to carry or store program code in the form of computer-executable instructions or data structures and that can be accessed by a processor of a general purpose or special purpose computer. Combinations of the above should also be included within the scope of computer-readable media.

Computer-executable instructions comprise, for example, instructions and data that cause a processor of a general purpose computer or a special purpose computer to perform a certain function or group of functions. Although the subject matter is described herein in language specific to methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific acts described herein. Rather, the specific acts described herein are disclosed as example forms of implementing the claims.

As discussed above mouse scanner 10 includes four laser motion sensors 22 and a CMOS sensor type camera 14 to capture the image underneath the mouse scanner housing 12. When scanner button is pressed by an operator (or if an automatic scanning process is initiated) an image acquisition function performed by main board 24 (e.g. by the processor 206 performing instructions stored on a ROM 208 or on a flash EEPROM 210) returns raw image data from camera 14 and sensor coordinates and state from laser motion sensors 22. Laser motion sensor state includes a lift bit. The lift bit indicates that the sensor is lifted from the surface, i.e. too far from the surface of the document being scanned to provide accurate position information. This can happen when the document surface is uneven, such as folded or bent pages or near the spine of a book. If the lift bit is set, the position data from that sensor may not accurately represent the movement of the mouse scanner and may be invalid and not used in the present invention for registration of the associated frame or tile.

The resolution of camera 14 is 300 dpi, for example. Images are acquired 10 times per second, for example, as mouse scanner 10 is moved across and down the page by an operator. Typically the movement of the mouse scanner 10 by the operator is a across one row, down one column, back across the next row, and so on. To avoid dropped frames during peak processing load, image acquisition may be run in a separate thread, or possibly of higher priority in some embodiments. The size of the FIFO for sending images to the main thread should not exceed 5 as delays higher than 0.5 sec are unacceptable.

The image acquisition procedure drops frames if the mouse does not move in an embodiment. This saves CPU time on image processing and reduces load on loop correction. However, frames with all four lift bits set should not be dropped and should be processed so that the application can stop the image acquisition procedure when the mouse scanner 10 has been completely lifted off the page by the operator (thus indicating scanning should be stopped).

FIG. 3 is a general flow diagram of the image acquisition procedure of the present invention. The procedure starts at step 710 when mouse scanner 10 is placed on the document to be scanned. Scanning begins when an operator presses scan button 20 and a new frame is captured by camera 14 in step 712. At the same time the new frame is captured the position of that frame is indicated by position data input from laser motion sensors 22 at step 714. The raw image (VGA) for that frame is stored (step 716) in computer 250, for example, correlated with its position data input from laser motion sensors 22.

In mouse scanner 10 non-uniform lighting and an inexpensive lens in camera 14 can cause a noticeable shadow in the raw image. In an embodiment of the present invention, shadow correction (step 718) is applied to the raw image (VGA) to produced a corrected image (VGA) that is stored in computer 250 (step 720) in place of the raw image.

Dewarping and demosaicing of the corrected image frame is next performed in step 722. Lookup table based dewarping is used. The lookup table is stored in a calibration file.

Good demosaicing algorithms are computationally expensive. Processing time seems to have a higher priority than image quality, so special alignment of pixels of different color is determined to be enough. One pixel has to be generated in the output color image for each quad shown in FIG. 4, which is a pixel quad in Bayer mosaic. This results in a quarter (QVGA) of the maximum resolution of the original VGA image (step 724). The green pixel value can be obtained by averaging 2 green pixels in the raw image (step 726). To account for the offset between color channels, the dewarping lookup table coordinates are changed by (−¼, +¼) and (+¼, ¼) for red and blue pixels correspondingly.

Bilinear interpolation should be enough to obtain dewarped color image.

On the other hand, the quality of images used for registration is important. It is possible to take green channel pixels of the raw image (effectively 320×480) and interpolate missing pixels to obtain a VGA size image. Bicubic interpolation is preferred in dewarping. Therefore, interpolation is performed two times in this scenario.

Alternatively, we can apply bicubic interpolation to original green pixels of the raw image. In this case scan lines appear to be rotated by 45°. FIG. 11 illustrates options in dewarping.

A preferred embodiment uses a QVGA size green channel image (from step 726) for registration. Pixels of that image are obtained by averaging the two green pixels of each quad. In the present invention, as each step in the image processing is performed, the resultant image is stored in computer 250 for further processing, registration or rendering. Each resultant image frame is stored with its corresponding position data.

As mentioned previously laser motion sensor 22 position data includes lift bits that are set by mouse scanner 10 firmware in EEPROM 210, for example, when a laser motion sensor 22 is lifted off the document that is being scanned. Since lifted sensors do not generate a valid position coordinate, they are detected in step 728 and then ignored in one stage of the transform estimation (step 730).

As part of or a prelude to registration, the relative transform between adjacent frames is estimated based on the sensor coordinates that are valid for both images.

Transform estimation (step 730 in FIG. 3) is described in detail in the following section.

Transform Estimation (Step 730)

The transformation estimation process is shown generally in the flowchart of FIG. 6. The process starts with the scan button 20 being pressed (step 1210). Once the scan button 10 is pressed, the image capturing unit, i.e. camera 14, begins capturing frames, i.e. frame i, frame i+1, frame i+2, etc. at, for example, 10 times per second as mouse scanner 10 is moved across and down the page by an operator. As discussed previously, at the same time the new frame is captured the position of that frame is indicated by position data input from laser motion sensors 22 (step 1212). Given position data of 2 to 4 sensors from two frames, the transformation parameters can be estimated (step 1214). As is known, transformation parameters allow pixel locations in one frame to be transformed or mapped into the image space of another frame, or into a common image space. Once we have the transformation parameters we can stitch or blend the two frames together to form a composite image. One of the issues addressed by the present invention is that the position data, which is the keystone of relating one frame to another, is not always accurate. We have to estimate, accurately, the position data for each frame. To do this we developed a confidence measurement of the accuracy of the position data that we use for the parameter estimation (step 1216).

For rigid body transformation, the transformation of the point p″(x″,y″,1) (e.g. a point in frame i+1) to p′(x′,y′,1) (e.g. a point in frame i) can be expressed as

$\begin{pmatrix} x^{\prime} \\ y^{\prime} \\ 1 \end{pmatrix} = {\begin{pmatrix} {\cos \; \theta} & {\sin \; \theta} & {tx} \\ {{- \sin}\; \theta} & {\cos \; \theta} & {ty} \\ 0 & 0 & 1 \end{pmatrix}{\begin{pmatrix} x^{''} \\ y^{''} \\ 1 \end{pmatrix}.}}$

From the sensor data, we can get the sensor position. Let (x_(i)(j),y_(i)(j)) be the position of sensor j in frame i. Then sensor coordinates related to the image center can be calculated as (X_(i)(j),Y_(i)(j))=(x_(i)(j)+Sx(j), y_(i)(j)+Sy(j)), where (Sx(j),Sy(j)) are coordinates of sensor j relative to the image center in sensor units.

We can obtain up to 4 pairs of sensor positions related to frame i and frame i+1. One pair is sensor S1 position data for frame i and frame i+1, another pair is sensor S2 position data for frame i and frame i+1, and so on.

The transformation parameter estimation is used later to obtain a registration parameter (tx_(i),ty_(i),θ_(i)) that is utilized in registering a plurality of image frames to form a composite image.

Parameter Estimation

For a jth sensor point p2_(i)(j)=(X_(i)(j),Y_(i)(j)) in the frame i to be corresponding to p1_(i+i)(j)=(X_(i+i)(j),Y_(i+i)(j)) in the frame i+1, the transformation relationship is described as follows.

X _(i)(j)=X _(i+1)(j)cos θ_(i) +Y _(i+1)(j)sin θ_(i) +tx _(i)

Y _(i)(j)=Y _(i+1)(j)cos θ_(i) −X _(i+1)(j)sin θ_(i) +ty _(i)

However, in the real world environment, the laser sensors 22 are not perfectly accurate in reporting the position of mouse scanner 10. This results in a sensor error that is a difference between the actual sensor location (position data) and the sensor location computed from the transformation relationship. The sensor error e^(i)(j)=(e_(x) ^(i),e_(y) ^(i)) for the jth sensor point pair (X_(i)(j),Y_(i)(j)) in frame i and (X_(i+1)(j),Y_(i+1)(j)) in frame i+1 are expressed as

e _(x) ^(i)(j)=X _(i+1)(j)cos θ_(i) +Y _(i+1)(j)sin θ_(i) +tx _(i) X _(i)(j)

e _(y) ^(i)(j)=Y _(i+1)(j)cos θ_(i) −X _(i+1)(j)sin θ_(i) +ty _(i) −Y _(i)(j)

We can obtain the error measurement e for the jth sensor point pair, where j=1 . . . 4

$e = \begin{bmatrix} {e_{x}(1)} \\ {e_{y}(1)} \\ {e_{x}(2)} \\ {e_{y\;}(2)} \\ {e_{x}(3)} \\ {e_{y\;}(3)} \\ {e_{x}(4)} \\ {e_{y}(4)} \end{bmatrix}$

We will have 8 elements in the error measurement vector e.

The k-th row of the Jacobian matrix J is:

$J_{k} = {\left\lbrack {\frac{\partial e_{k}}{\partial{tx}}\frac{\partial e_{k}}{\partial{ty}}\frac{\partial e_{k}}{\partial\theta}} \right\rbrack.}$

We can use an iterative method to estimate the parameter given an initial parameter t=(tx_(i),ty_(i), θ_(i))=(0,0,0). Gaussian Newton's method computes a vector of corrections c to be subtracted from the current pair-wise alignments estimation:

{circumflex over (t)}=t−c where c=(J ^(T) J)⁻¹ J ^(T) e.

We use weighted least-square minimization by considering the sensor lift situation. If a sensor is lifted, the weight for the error related to the sensor will be set to zero. The weighted least-square equation is

WJc=We where W is a diagonal matrix consisting of weights for each error.

For example, if the jth sensor is lifted, the weight for the error related to the sensor is set to 0.

W(2*j)=0

W(2*j+1)=0

The determination of whether a sensor is off-page or invalid (reporting incorrect position data) is detailed in the below section entitled “Off Page Detection.” This is shown generally as step 1218 in FIG. 6. Generally, each sensor reports a “lift bit” that indicates that a sensor is too far from the page to correctly report position data. However, sometimes the sensor is lifted (off-page) but this condition is not reported. So, in the present invention, we use the registration error and compare it to an empirically determined threshold to decide if at least one of the sensors is actually off-page and/or invalid.

In addition, we use weight to consider the geometric properties of sensor location. If the 4 sensors are not formed in a square, the errors from horizontal and vertical pairs are weighted differently to improve the accuracy. For example, in the embodiment shown in FIG. 1, the 4 sensors S1-S4 are formed in a rectangle so we weight the errors from the horizontal and vertical pairs differently.

WeightFactor=sqrt(Y _(—) X_Ratio);

Where Y_X_Ratio is the ratio of vertical distance and horizontal distance of the rectangle formed by four sensors.

W(2*j)=1

W(2*j+1)=WeightFactor

Once the weight matrix is decided, the weighted least minimization can be done by c=(J^(T)W^(T)WJ)⁻¹J^(T)W^(T)We.

In an embodiment of the present invention, we remove the error elements if the weights are zeros for the lifted sensor (step 1220 in FIG. 6). As a result, the error measurement vector e will have K elements, and the Jacobian matrix J will be K by 3.

K=2*m, where m (m<=4) is the number of valid sensors.

K is the number of equations for the 3 unknowns. As a result, it requires K>=3 so that at least 2 valid sensor readings are needed. Once we have excluded the invalid sensor data, we re-estimate the transformation parameters (step 1222) as outlined above, and re-calculate the sensor data error and re-measure the confidence that the transformation parameters are true (step 1224). Once the transformation parameters have been re-estimated this part of the process ends (step 1226), and the process moves to registration of frames (step 732 in FIG. 3). However, before moving on to registration, we discuss confidence measurement and off-page detection in the following sections.

Confidence Measurement

Having removed the sensor registration error as described above, we now perform a confidence measurement of the transformation parameters. The covariance matrix (sometimes referred to as the variance-covariance matrix), Qxx, is defined as Q_(xx)=(J^(t)WJ)⁻¹

The covariance matrix, Qxx, contains the variance of each unknown and the covariance of each pair of unknowns.

For any set of quantities, an error ellipse can be calculated. The dimensions and orientations of the ellipse are calculated from the coefficients of the covariance matrix.

The ellipse matrix is composed of entries from the covariance matrix. For example, a three-dimensional error ellipsoid is computed from

$Q_{xx}^{\prime} = \begin{bmatrix} q_{aa} & q_{ab} & q_{ac} \\ q_{ba} & q_{ba} & q_{bc} \\ q_{ca} & q_{cb} & q_{cc} \end{bmatrix}$

where covariance values from the covariance matrix Qxx, and a, b, and c are the indices for the unknowns for which the ellipse is computed.

If only angle confidence is to be measured, the covariance matrix has only one element Q′xx=Qxx(3,3).

The quantities in Qxx need to be scaled by a reference variance. This reference variance, S₀ ², is related to the weighting matrix and the residuals by the equation

${S_{0}^{2} = \frac{e^{t}W\; e}{r}},$

where r is the number of degrees of freedom (i.e., the number of equations minus the number of unknowns).

r=K−3=2*m−3 where m (m<=4) is number of valid sensors.

The error ellipse semi-axes are given by S_(axis)=±√{square root over (S₀ ²eigenvalue_(axis)(Q′xx))}.

The orientation of the error ellipse is the column eigenvectors of Q′xx.

To determine the error to a specific confidence level, the length of the semi-axis is multiplied by a confidence factor based on the Fisher distribution using the formula S_(axis%)=S_(axis)√{square root over (2Fisher(1−confidence,#unknowns,r))}, where the confidence is a number from 0 to 1, with 1 being complete confidence, and r is the number of degrees of freedom.

The Fisher distribution is determined from the equation

$\alpha {\int_{{Fisher}{({\alpha,v_{1},v_{2}})}}^{\infty}{\frac{\Gamma \left( {\left( {v_{1} + v_{2}} \right)/2} \right)}{{\Gamma \left( {v_{1}/2} \right)}{\Gamma \left( {v_{2}/2} \right)}}{\left( \frac{v_{1}}{v_{2}} \right)\ }^{v_{1}/2}\frac{x^{{({v_{1} - 2})}/2}}{\left\lbrack {1 + \left( {v_{1}/v_{2}} \right)} \right\rbrack x^{{({v_{1} + v_{2}})}/2}}{x}}}$

where the Gamma function is given by

Γ(v) = ∫₀^(∞)u^(v − 1)e^(−u) u.

The error ellipse can be computed for any confidence level. The Fisher distribution needs to be computed for the selected confidence. We can calculate the error ellipse at 95% confidence level.

The meaning of the 95% confidence error ellipse is that there is 95% probability that the true parameters will remain within the area specified by the ellipse. As expected, as more sensors are used in the computation, the area of the ellipse becomes smaller. If the estimated values lie closer to the true parameter, this will also reduce the ellipse area.

As a result, we may choose a threshold to trust sensor estimation if

S _(axis %) <T

T is a parameter to be set experimentally.

The error ellipse at 95% confidence level may be used as a dynamic search area for registration or we can produce a confidence value between 0-1 by a confidence function confidence=f(S_(axis %)).

For example, the confidence function may use ƒ(x)=e^(−x) ² ^(/σ) ² where σ is a parameter to be set experimentally.

Off Page Detection (Step 1218 in FIG. 6)

Laser sensors 22 being off page is a major problem that affects the registration accuracy, especially when the sensor do not correctly report the “lift bit.”

As discussed above regarding the confidence measure of the sensor estimation, we can estimate the error ellipse of (Tx, Ty).

The covariance matrix (sometimes referred to as the variance-covariance matrix), Qxx, is defined as

Q _(xx)=(J ^(t) WJ)⁻¹

In order to calculate the error ellipse of (Tx, Ty),

$Q_{xx}^{\prime} = \begin{bmatrix} {{Qxx}\left( {1,1} \right)} & {{Qxx}\left( {1,2} \right)} \\ {{Qxx}\left( {2,1} \right)} & {{Qxx}\left( {2,2} \right)} \end{bmatrix}$

The error ellipse semi-axes are given by

S _(axis)=±√{square root over (S ₀ ²eigenvalue_(axis)(Q′xx))}

To detect a sensor “off page” condition, we calculate the semi-axis of the error ellipse as follows:

Sx _(axis)=±√{square root over (S ₀ ² *Q′xx(1,1))}

Sy _(axis)=±√{square root over (S ₀ ² *Q′xx(2,2))}

The registration error is

Se=√{square root over (Sx _(axis) ² +Sy _(axis) ²)}=S ₀*√{square root over (Q′xx(1,1)+Q′xx(2,2))}{square root over (Q′xx(1,1)+Q′xx(2,2))}

If the registration error is large, we draw the conclusion that at least one of the sensors is off page. We compare the error to a threshold to make such conclusion. The threshold is determined empirically for a particular device by scanning one or more images under a variety of conditions with one or more sensors off-page and measuring the error for each of those test conditions.

Off Page Sensor Detection and Re-Estimation

We will set a sensor as invalid based on the assumption that the off page sensor will have less motion length because the sensor stops increasing position values when it is off page. The following summarizes the process steps.

Step 1:

We will initially use all no-lift sensors to estimate the transformation, and calculate the Se value from the parameter estimation.

Step 2:

If the Se is greater than T_high (empirically determined threshold, e.g. 5) and there are more than T_low (empirically determined threshold, e.g. 3) sensors that reported no lift, we will calculate the motion vector of the valid sensors.

Step 3:

We choose the sensor that has less than the average motion length to be invalid.

We next describe the registration aspect of the present invention, which is shown generally as step 732 in FIG. 3.

Registration (Step 732 in FIG. 3)

In the present invention we provide a method to stitch a pair of images together. The stitching algorithm of the present invention involves minimization of a cost function that consists of registration errors from the image data of the two images, as well as the estimated errors from the set of sensors. The weight function in the cost function derived from the confidence value of sensor estimation which considered the sensor errors including lift and off page as well as a measure of accuracy of the sensor readings. The algorithm of the present invention uses weights to adjust image registration accuracy against sensor accuracy to produce a set of registration parameters that would best stitch the two images together. As a result, in the low content area, the sensor data has more weight than image data while in rich content area the image data will have more weight than sensor data. Therefore, the pair-wise image registration can achieve higher accuracy by fusing information from both sensor data and image data. In order to handle large errors for initial registration parameters and to avoid local minima in the minimization process, the image pair may be registered in lower resolution and then refined in high resolution. A detailed explanation is provided as follows.

Pair-wise image registration based on corner matches may fail or be inaccurate if there are no or few salient corners inside the overlapping area of the pair of images. As a result, we may need to refine the registration from initial registration using a feature-based method or using the sensor data. In the present invention, we perform registration by integrating image data and sensor data.

Pair-Wise Image Registration Based on Rigid Body Transform Model

FIG. 7 illustrates the relationship of two frames, frame i and frame i+1, with pixel point p′ in frame i and a corresponding pixel point p″ in frame i+1. The two frames are disposed to one another at an angle θ in a common x-y coordinate space, and have an overlap area identified with a black dot therein. The transformation matrix for aligning frame i to frame i+1

$M_{i} = \begin{pmatrix} {\cos \; \theta_{i}} & {\sin \; \theta_{i}} & {tx}_{i} \\ {{- \sin}\; \theta_{i}} & {\cos \; \theta_{i}} & {ty}_{i} \\ 0 & 0 & 1 \end{pmatrix}$

The transformation relationship of the point p_(i)(j)=(X_(i)(j),Y_(i)(j)) to the point p_(i+1)(j)=(X_(i+1)(j),Y_(i+1)(j)) can be expressed as follows:

X _(i)(j)=X _(i+1)(j)cos θ_(i) +Y _(i+1)(j)sin θ_(i) +tx _(i)

Y _(i)(j)=Y _(i+1)(j)cos θ_(i) −X _(i+1)(j)sin θ_(i) +ty _(i).

Registration Using Sensor Data

Registration parameter estimation from sensor data is described in the forgoing discussion of “Transform Estimation.”

We extracted the matched pairs of valid sensor coordinates which are stored in arrays named pt1 and pt2, for example, in RAM 204.

The sensor error e(j)=(e_(x),e_(y)) for the jth sensor point pair (pt1[j].fX,pt1[j].fY) in a template (second) frame and (pt2[j].fX,pt2[j].fY) in a reference (first) frame are expressed as

e _(x)(j)=pt1(j).fX*cos θ−pt1(j),fY*sin θ+tx−pt2(j).fX

e _(y)(j)=pt1(j).fX*sin θ+pt1(j).fY*cos θ+ty−pt2(j).fY

We obtain the error measurement e for j=1 . . . 4

$e = \begin{bmatrix} {e_{x}(1)} \\ {e_{y}(1)} \\ {e_{x}(2)} \\ {e_{y\;}(2)} \\ {e_{x}(3)} \\ {e_{y\;}(3)} \\ {e_{x}(4)} \\ {e_{y}(4)} \end{bmatrix}$

We will have 8 elements in the error measurement vector e.

The k-th row of the Jacobian matrix J is

$J_{k} = \left\lbrack {\frac{\partial e_{k}}{\partial{tx}}\frac{\partial e_{k}}{\partial{ty}}\frac{\partial e_{k}}{\partial\theta}} \right\rbrack$

The cost function of registration parameter estimation is given as

${ES} = {{\sum\limits_{j = 1}^{4}\left( {{e_{x}(j)}^{2} + {e_{y}(j)}^{2}} \right)} = {\sum\limits_{k = 1}^{8}{e(k)}^{2}}}$

From the sensor data, we obtain the estimated parameters based on an iterative method minimizing the errors (tx, ty, theta) and confidence measurement based on the semi-axis of error ellipse for translation (S_Tran).

Registration Using Image Data

Registration using image data is formulated as a minimization problem. In order to register the two frames, the overlapping area can be extracted based on registration parameter estimated from sensor data. FIG. 8 illustrates two frames, Frames 16 and 17, which were scanned with mouse scanner 10 with their positions recorded by laser sensors 22.

Based on the sensor data, the initial estimation of the registration parameter, as described in the forgoing sections, is obtained as:

Tx=18.2946, Ty=−2.0619 and Theta=−0.0320

The semi-axis of the error ellipse for translation is 0.7281, which is at 95% confidence level.

The overlapping area is extracted from the second frame, Frame 17, which is used as a template:

tmplt=SecondImg(y1:y2,x1:x2). FIG. 9 illustrates the overlap area.

The 4 points of the rectangle of the tmplt are:

[x1, y1], [x2, y1], [x1, y2], [x2, y2].

The registration based on the image data involves matching pixels in the template image (second frame) to those pixels in the reference image (first frame).

Let T be an (n by m) image template, which can be considered as a matrix. Let x=(u,v) be the (2×1) vector containing the coordinates of a pixel: (u, v)ε{1, 2 . . . n}×{1, 2 . . . m}. Thus T(x) is the intensity of the pixel x.

Let p be the registration parameter vector, p=(tx,ty,θ), the transformation matrix of p is M(p) as

${M(p)} = {{M\left( {{tx},{ty},\theta} \right)} = \begin{pmatrix} {\cos \; \theta} & {\sin \; \theta} & {tx} \\ {{- \sin}\; \theta} & {\cos \; \theta} & {ty} \\ 0 & 0 & 1 \end{pmatrix}}$

If p=0=(0,0,0), the M(0) is the identity matrix

${M(0)} = {{M\left( {0,0,0} \right)} = \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}}$

The map w which maps the pixel x in the template image to the corresponding pixel in the reference image according to parameter p is defined as w(x; p)

${W\left( {x;p} \right)} = {{W\left( {\begin{bmatrix} u \\ v \end{bmatrix},\begin{bmatrix} {tx} \\ {ty} \\ \theta \end{bmatrix}} \right)} = {\begin{pmatrix} {W_{u}(p)} \\ {W_{v}(p)} \end{pmatrix} = \begin{pmatrix} {{\cos \; \theta*u} + {\sin \; \theta*v} + {tx}} \\ {{{- \sin}\; \theta*u} + {\cos \; \theta \; v} + {ty}} \end{pmatrix}}}$

Let q=nm be the total number of the pixels in the template image T.

We need to map q pixels into the reference image. For each pixel, x(k)=(u(k),v(k)), the mapping point in the reference image is W(x(k);p), k=1 . . . q.

Let I be the reference image, where I(W(x;p)) is the intensity of mapped point W(x;p) corresponding to pixel x in the template image according to current registration parameter p.

Assuming the illumination is constant, the intensity of pixel x in template image T(x) will be matched or the same as the intensity I(W(x;p)) of mapped pixel in the reference image if the registration parameter p is correct.

The registration refinement can be described by the minimization problem:

$\begin{matrix} {{EI} = {\min\limits_{p}{{{I\left( {W\left( {x;p} \right)} \right)} - {T(x)}}}_{2}}} \\ {= {\min\limits_{p}\left( {{I\left( {W\left( {x;p} \right)} \right)} - {T(x)}} \right)^{2}}} \\ {= {\min\limits_{p}{\sum\limits_{k = 1}^{q}\left( {I\left( {{W\left( {{x(k)};p} \right)} - {T\left( {x(k)} \right)}} \right)}^{2} \right.}}} \end{matrix}$

where k=1 . . . q, and q=nm is the total number of pixels in the template image.

In order to solve the minimization problem, a Gauss-Newton, a Newton, a steepest-descent, or ESM method may be used.

A preferred embodiment is based on Lucas-Kanade Algorithm (which is a Gauss-Newton gradient descent non-linear optimization algorithm).

We make the assumption that our initial parameters from the sensor data or a few matched corner pairs are near to the optimal solution so that gradient least-square optimization is used in the area-based registration procedure.

For the pixel x(k) in the template image, the error measurement e_(k)=I(W(x(k),p))−T(x(k)) is the intensity difference, k=1 . . . q, where q is the total number of pixels in the template.

The k-th row of the Jacobian matrix J corresponding to e_(k) is

$J_{k} = {\left\lbrack {\frac{\partial e_{k}}{\partial p_{1}}\frac{\partial e_{k}}{\partial p_{2}}\frac{\partial e_{k}}{\partial p_{3}}} \right\rbrack = {\left\lbrack {\frac{\partial e_{k}}{\partial{tx}}\frac{\partial e_{k}}{\partial{ty}}\frac{\partial e_{k}}{\partial\theta}} \right\rbrack.}}$

The error measurement e is a (q by 1) vector and J is a (q by 3) matrix, where q is the total number of pixels in the template image.

The correction vector c is calculated as:

Δp=−(J ^(T) J)⁻¹ J ^(T) e.

For each iteration the p is update by Δp

p←p+Δp

until Δp<ε is very small or we have reached the maximum iteration.

Registration Integrating Image and Sensor Data

In order to integrate the sensor and image data, the registration is formulated as a minimization of a cost function:

$\begin{matrix} {E = {{EI} + {\lambda \; {ES}}}} \\ {= {\sum\limits_{k = 1}^{q}\left( {{I\left( {{W\left( {{x(k)};p} \right)} - {T\left( {x(k)} \right)}} \right)}^{2} + {\lambda {\sum\limits_{j = 1}^{l}{\left( {{e_{x}(j)}^{2} + {e_{y}(j)}^{2}} \right).}}}} \right.}} \end{matrix}$

In order to distinguish the error from image data and error from sensor data, let ei(k)=I(W(x(k);p)−T(x(k)), where k=1 . . . q, q is total number of pixel in template image, es(2j−1)=e_(x)(j), es(2j)=e_(y)(j). And j=1 . . . l, where l is number of valid sensors.

If we produce a new error measurement vector

$e = \begin{bmatrix} {ei} \\ {\lambda*{es}} \end{bmatrix}$

The new error vector has K=q+2*l elements. Thus the cost function is

$\begin{matrix} {E = {{EI} + {\lambda \; {ES}}}} \\ {= {\sum\limits_{k = 1}^{q}\left( {{I\left( {{W\left( {{x(k)};p} \right)} - {T\left( {x(k)} \right)}} \right)}^{2} + {\lambda {\sum\limits_{j = 1}^{l}\left( {{e_{x}(j)}^{2} + {e_{y}(j)}^{2}} \right)}}} \right.}} \\ {= {\sum\limits_{k = 1}^{K}{{e(k)}^{2}.}}} \end{matrix}$

The new Jacobian matrix can be obtained by

$J = {\begin{bmatrix} {JI} \\ {\lambda*{JS}} \end{bmatrix}.}$

The new Jacobian matrix is a K by 3 matrix.

Using pseudo-inverse of Jacobian matrix, we can obtain

Δp=−(J ^(T) J)⁻¹ J ^(T) e.

For each iteration the p is update by Δp

p←p+Δp

until Δp<ε is very small or we have reached the maximum iteration.

Weight function integrating image and sensor data

In order to fuse the two error functions from EI and Es, we need find a proper weight function. According to our investigation, we may choose a simple weight function for the pair-wise registration:

λ=WeightCon/S_Tran so that the cost function will be

-   -   E=EI+WeightCon/S_Tran*Es and WeightCon is a constant=200, which         we determined experimentally.

S_Tran is the semi-axis of error ellipse described above in Transform Estimation (step 730).

If the sensor data is reliable, the weight should be large, so that the λEs will have a large penalty when the current registration parameter is going away from initial estimated position from sensor data. As a result, the cost function E=EI+λEs will be dominated by λEs so that its minimum is close to the minimum of Es.

If the sensor data is unreliable, the weight should be small, so that λEs will be flat, so that the penalty will be very small when current registration parameter is going away from initial estimation position from sensor data. As a result, the cost function E=EI+λEs will be dominated by EI so that its minimum is close to the minimum of EI.

By adjusting the weight, we will be able to adjust how to balance EI and Es. If sensor data is reliable, we trust the sensor data more. If sensor data is not reliable, we will trust the intensity based registration from the image data more.

Since we use S_Tran to evaluate the sensor confidence, the S_Tran is the semi-axis of error ellipse. The larger S_Tran means less reliable sensor data.

If the sensor data is reliable, the semi-axis of error ellipse, S_Tran, is close to 0. The weight will be very large. As a result, we trust the sensor data much more.

If the sensor data is not reliable, the semi-axis of error ellipse, S_Tran, is very large. The weight will be very small. As a result, we rely much less on sensor data.

In addition, we treat all sensor pairs equally when we estimate the S_Tran from only two sensors. According to our prior knowledge, the errors estimated from the longer pair of two sensors are much less than the errors estimated from the shorter pair of two sensors. As a result, the calculation of S_Tran may need to be modified according to suit a particular sensor geometry.

Refine Registration from Low Resolution to High Resolution

An assumption in the above procedure is that the initial parameters from the sensors are close to the optimal or true values.

If the sensor data is not reliable, the initial estimation of registration parameters will be far from the true values. As a result, it may not converge or converge into a local minimum.

Based on the semi-axis of error ellipse, we know with a 95% confidence level what the true value should be.

If the sensor is reliable, the S_Tran is small, typically less than 1 pixel, so that there is no need for registration at a lower resolution. The method of the present invention has been shown to register the images even if the initial guess is 5 to 8 pixels too far from the true value.

If the sensor is unreliable, the S_Tran is typically 3 to 10 pixels, so that we may use our method to register in low resolution of ½.

If there a very large error, the S_Tran may be over 20 pixels, so that we may use our method to register in even lower resolution of ¼.

FIG. 10 illustrates the general flow. In step 2210, the sensor data, the estimated transformation parameters and sensor confidence are obtained as outlined above in the section entitled “Transform estimation (step 730).” If the sensor confidence is high, i.e. S_Tran is small, typically less than a few pixels (step 2212 returns Yes), we register the frames in high resolution (step 2214) as outlined above. If the sensor confidence is low, i.e. S_Tran is high, typically more than a few pixels (step 2212 returns No), we downsample the reference and test images (i.e. second and first frames) to achieve a lower resolution (step 2218) and register the frames first in low resolution as outlined above. The low resolution we choose, ¼ or ½, depends on the degree of the error. After this initial registration, we then refine the registration the frames again by repeating the registration steps outlined above using the higher resolution image frames.

Loop Correction (Step 738 in FIG. 3)

The following is a discussion of the loop correction aspect of present invention. Pair-wise image stitching based on pair-wise alignment may result in accumulated errors if each frame overlaps only with the previous frame. When scanning an image, mouse scanner 10 is moved across a document from left to right, and then down, and then right to left, for example. Each frame will usually overlap with a frame to its right and/or left and a frame above and/or below it. If we go back to a prior captured frame (captured before the immediately previous frame) a “close-the-loop condition” is detected if we can align the current frame with this prior captured frame, which may be part of the image above or below the current frame, for example. We generally assume all pair-wise registrations are successful. However, if a break happened, the pair-wise registration will not be available. The new frame after break will be allocated in a new place according to the transform matrix from sensor data until a closed loop is identified. The close-the-loop correction will assign all errors to the frame where the break happened. Assuming the break happened between frames i and i+1 (FIG. 11). Then a prior (prior to frame i) captured frame n must be registered with frame i+1 to form a closed loop (FIG. 12). T₁ is a transformation matrix between frames i and i+1:

T _(i)=(T ₁ T ₂ . . . T _(i−1))⁻¹(T _(i+1) . . . T _(n))⁻¹

Once T_(i) is calculated, the closed loop will be fixed.

If a pair-wise registration has been corrected by a closed loop, the pair-wise registration will be set “fixed” as shown in FIG. 12. We will not change the pair-wise registration any further once it is “fixed”.

There are a few cases that we pay attention to for new loop identification. For example, a closed loop contains a closed loop for a spiral scanning, or a new closed loop inside a closed loop. We list two possible cases.

Case 1, the new loop contains one or more closed loops (FIG. 13).

As shown in FIG. 13, a new loop contains a closed loop, which has been corrected. Frames from 1 to N are extracted for the new loop (the outer loop), but frames K to L (the inner loop) are already corrected.

The new loop is extracted from frame 1 to N. We may refer the extracted frames from 1 to n as shown as the lower row in FIG. 14.

We will obtain an index vector, which contains only the non-fixed frame numbers. For the above example, we will have index vector of size (N−(L−K)), which contains the frame number [1, . . . K,L+1 . . . N]

Case 2, the new loop is inside a closed loop (FIG. 15).

The new loop is extracted from frame K to N (FIG. 16). We may refer the extracted frames from 1 to n as shown as the lower row in FIG. 17.

We will obtain an index vector, which contains only the non-fixed frame numbers. For the above example, we will have index vector of size (N−L) or (n−k), which contains the frame number [L+1 . . . N] or [k+1 . . . n].

The global optimization will then process the extracted loop, but it is only to correct the non-fixed pair-wise registration recorded in the index vector.

The following are discussions of modification of the algorithm for certain situations.

Single Loop Correction with Break Frame

The following is a discussion of the correction for the closed loop with a break between frames i and i+1.

According to the global constraint of the closed loop T₁T₂ . . . T_(i) . . . T_(n)=I, where I is the identity matrix

$\begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}.$

Combining the N pair-wise transformation matrices T_(i) will bring us back to the same frame where we started, i.e. frame 1 (i=1), thus registering the last frame of the loop with the first frame and thereby closing the loop.

We assign all errors to the pair-wise registration between frames i and i+1, and as a result, T_(i)=(T₁T₂ . . . T_(i−1))⁻¹(T_(i+1) . . . T_(n))⁻¹

$T_{i} = {\begin{bmatrix} {\cos \; \theta_{i}} & {\sin \; \theta_{i}} & {tx}_{i} \\ {{- \sin}\; \theta_{i}} & {\cos \; \theta_{i}} & {ty}_{i} \\ 0 & 0 & 1 \end{bmatrix}.}$

We will update the pair-wise registration parameters tx_(i), ty_(i) and θ_(i) according to the transformation matrix. Once the pair-wise registration of frame i to i+1 is updated, the display of image frame from i+1 to frame n will be updated, and all pair-wise registrations from 1 to n are set to ‘fixed’.

Correction of close loop with fixed frames

index=[1 . . . k,l+1, . . . n] vector is size of n′ (n′=n−l+k) (FIG. 14).

index=[k+1, . . . n] vector is size of n′ (n′=n−k) (FIG. 17).

We will have global constraints for the closed loop.

T ₁ T ₂ . . . T _(i) . . . T _(n) =I

We get three independent scalar constraints to minimize.

  e₁ = sin (θ₁ + … + θ_(n)) e₂ = tx₁ + tx₂cos  θ₁ + ty₂sin  θ₁ + tx₃cos (θ₁ + θ₂) + ty₃sin (θ₁ + θ₂) + … + tx_(n)cos (θ₁ + … + θ_(n − 1)) + ty_(n)sin (θ₁ + … + θ_(n − 1)) e₃ = ty₁ − tx₂sin  θ₁ + ty₂cos  θ₁ − tx₃sin (θ₁ + θ₂) + ty₃cos (θ₁ + θ₂) + … + tx_(n)cos (θ₁ + … + θ_(n − 1)) + ty_(n)cos (θ₁ + … + θ_(n − 1))

From frame k+1 to 1, they are fixed so that the pair-wise registration parameters (tx_(i),ty_(i),θ_(i)) i=k+1 . . . l will be treated as constants.

We will not include error measurements for the fixed pair-wise registration. As a result, we will obtain the error measurements for non-fixed pair-wise registration and 3 global constraints. The e error measurement will have K elements.

$K = {3 + {2{\sum\limits_{i = 1}^{n^{\prime}}m_{i}}}}$

where the m_(i) is the number of matched feature points between frame index(i) and index(i)+1, n′ is the total number of non-fixed pair-wise registrations.

Since we will not correct the fixed pairs, the Jacobian matrix, J, will be K by 3*n′.

The kth row of the Jacobian matrix J is

$J_{k} = \left\lbrack {\frac{\partial e_{k}}{\partial{tx}_{{index}{(1)}}}\frac{\partial e_{k}}{\partial{ty}_{{index}{(1)}}}\frac{\partial e_{k}}{\partial\theta_{{index}{(1)}}}\mspace{14mu} \ldots \mspace{14mu} \frac{\partial e_{k}}{\partial{tx}_{{index}{(n)}}}\frac{\partial e_{k}}{\partial{ty}_{{index}{(n)}}}\frac{\partial e_{k}}{\partial\theta_{{index}{(n)}}}} \right\rbrack$

The correction vector c for non-fixed pair-wise registration will be 3*n′ by 1.

The correction vector c is calculated as

c=(J ^(T) J)⁻¹ J ^(T) e

Once we obtained the correction vector, we can update the non-fixed pair-wise registration estimation:

t ₂ =t ₂ −c

where t₂=(tx_(index(1)),ty_(index(1)),θ_(index(1)) . . . tx_(index(n)),ty_(index(n)),θ_(index(n))) is the current non-fixed pair-wise registration estimation (step 740 in FIG. 3).

By performing loop correction according to the present invention and then updating the frame coordinates, the scanned image is re-tensioned, i.e. the individual scanned frames are tightened together to approximate the original image. The scanned image can then be rendered (step 742 in FIG. 3) and the image can be displayed, projected, or printed, for example (step 744 in FIG. 3). Alternatively, or additionally, the scanned image can be subjected to known blending algorithms (step 746 in FIG. 3) that reduce noticeable overlap regions between adjacent frames. After blending, the image can be displayed, projected, or printed, for example (step 748 in FIG. 3), and the process ends (step 750 in FIG. 3).

Global Optimization for Close-the-Loop Error Minimization

As we discussed above, pair-wise image stitching based on pair-wise alignment will result in accumulated errors if each frame overlaps only with the previous frame. If we go back to an earlier frame, a close-the-loop is detected. Due to the accumulated errors, however, the loop may not close.

In the present invention, we employ a global minimization strategy to do backward correction to all the frame alignments. Close-the-loop can be detected by checking if there are significant overlaps between the current frame and earlier frames. The following describes the global optimization for close-the-loop error minimization using backwards correction.

The following is an exemplary implementation of loop correction by global optimization, with reference to FIG. 18.

(1) Identify a closed loop. If a closed loop is identified, estimate the pair-wise registration estimation (tx_(n),ty_(n),θ_(n)) from frame n to frame 1.

(2) Extract all (or selected) matched feature point pairs for pair-wise registration (step 3310 in FIG. 18). For example, the jth matched feature point pair (X_(i)(j),Y_(i)(j)) in frame i and (X_(i+1)(j),Y_(i+1)(j)) in frame i+1, j=1, j=1 . . . m_(i), where m_(i) is the number of matched feature points between frame i and i+1. The number of all the match feature point pairs is

$\sum\limits_{i = 1}^{n}{m_{i}.}$

(3) Get the current pair-wise registration estimation vector t=(tx₁,ty₁,θ₁ . . . tx_(n),ty_(n),θ_(n)). (step 3312)

(4) Calculate error measurement e, which include 3 global constraints and

$2{\sum\limits_{i = 1}^{n}m_{i}}$

matched feature point errors. (step 3314)

(5) Calculate Jacobian matrix when preparing the error measurement. J is a matrix of K by 3n,

$K = {3 + {2{\sum\limits_{i = 1}^{n}m_{i}}}}$

(6) Calculate the correction vector correction vector c is calculated as c=(J^(T)J)⁻¹J^(T)e. (step 3316)

(7) Update pair wise registration estimation {circumflex over (t)}=t−c (step 3318)

(8) If necessary (step 3320 returns No), repeat (4) to (7) by using the corrected registration t={circumflex over (t)} for next iteration until it converges or reached the maximum iterations (step 3320 returns Yes).

Weighted Least-Square Minimization

In an embodiment, we may use weighted least-square minimization. The weighted least-square equation is

WJc=We where W is a diagonal matrix consisting weight for each errors.

C=(J ^(T) W ^(T) WJ)⁻¹ J ^(T) W ^(T) We

We may introduce weight for each errors based on the uncertainties such as:

(a) estimation uncertainty for pair-wise registration—we may weight the confidence measure bases on such factors as resolution, or the number of feature points;

(b) feature point extraction errors—we may weight the strength of the errors; and/or

(c) distortion due to lift, tilting or camera calibration—we may weight laser data reliability.

The factors or error sources selected and the weight attributed to such will depend on each particular system will require empirical testing to understand the error sources and their impact on global optimization.

While the invention has been described in conjunction with several specific embodiments, it is evident to those skilled in the art that many further alternatives, modifications and variations will be apparent in light of the foregoing description. Thus, the invention described herein is intended to embrace all such alternatives, modifications, applications and variations as may fall within the spirit and scope of the appended claims. 

1. A method for correcting an error accumulated from a plurality of pair-wise registrations of image frames captured in sequence by a scanning device, comprising: using a processor to: identify a closed loop where a first image frame overlaps with a second image frame, the second image frame being captured earlier in the sequence than the first image frame; register the first image frame with the second image frame; and apply a global optimization to adjust registration parameters for the plurality of pair-wise registrations of image frames within the closed loop using global constraints.
 2. A method as in claim 1 wherein adjusting the registration parameters comprises calculating an error measurement that includes multiple global constraints.
 3. A method as in claim 2 wherein the global constraints comprise three independent scalar constraints.
 4. A method as in claim 2 further comprising extracting matched feature point pairs for the plurality of pair-wise registrations.
 5. A method as in claim 4 wherein calculating the error measurement further includes matched feature point errors.
 6. A method as in claim 1 further comprising: identifying a registration break in the closed loop, the registration break being between two consecutive frames i and i+1 in the sequence; assigning all registration errors in the closed loop to a pair-wise registration between frames i and i+1; and updating pair-wise transformation parameters according to a transformation matrix for frames i and i+1.
 7. A method as in claim 1 further comprising marking all pair-wise registrations of image frames within the closed loop as fixed.
 8. A method as in claim 7 wherein the registration parameters of pair-wise registrations of image frames within the closed loop that have been marked as fixed are not adjusted during the global optimization.
 9. An apparatus for correcting an error accumulated from a plurality of pair-wise registrations of image frames captured in sequence by a scanning device, comprising: a processor that: identifies a closed loop where a first image frame overlaps with a second image frame, the second image frame being captured earlier in the sequence than the first image frame; registers the first image frame with the second image frame; and applies a global optimization to adjust registration parameters for the plurality of pair-wise registrations of image frames within the closed loop using global constraints.
 10. An apparatus as in claim 9 wherein adjusting the registration parameters comprises calculating an error measurement that includes multiple global constraints.
 11. An apparatus as in claim 10 wherein the global constraints comprise three independent scalar constraints.
 12. An apparatus as in claim 10 wherein the processor further extracts matched feature point pairs for the plurality of pair-wise registrations.
 13. An apparatus as in claim 12 wherein calculating the error measurement further includes matched feature point errors.
 14. An apparatus as in claim 9 wherein the processor further identifies a registration break in the closed loop, the registration break being between two consecutive frames i and i+1 in the sequence; assigns all registration errors in the closed loop to a pair-wise registration between frames i and i+1; and updates pair-wise transformation parameters according to a transformation matrix for frames i and i+1.
 15. An apparatus as in claim 9 wherein the processor further marks all pair-wise registrations of image frames within the closed loop as fixed.
 16. An apparatus as in claim 15 wherein the registration parameters of pair-wise registrations of image frames within the closed loop that have been marked as fixed are not adjusted during the global optimization.
 17. One or more tangible, non-transitory computer-readable media having computer-readable instructions thereon, which, when executed by a processor, correct an error accumulated from a plurality of pair-wise registrations of image frames captured in sequence by a scanning device, wherein the processor: identifies a closed loop where a first image frame overlaps with a second image frame, the second image frame being captured earlier in the sequence than the first image frame; registers the first image frame with the second image frame; and applies a global optimization to adjust registration parameters for the plurality of pair-wise registrations of image frames within the closed loop using global constraints.
 18. One or more tangible, non-transitory computer-readable media as in claim 17 wherein adjusting the registration parameters comprises calculating an error measurement that includes multiple global constraints.
 19. One or more tangible, non-transitory computer-readable media as in claim 18 further comprising extracting matched feature point pairs for the plurality of pair-wise registrations.
 20. One or more tangible, non-transitory computer-readable media as in claim 18 wherein the processor further extracts matched feature point pairs for the plurality of pair-wise registrations.
 21. One or more tangible, non-transitory computer-readable media as in claim 20 wherein calculating the error measurement further includes matched feature point errors.
 22. One or more tangible, non-transitory computer-readable media as in claim 17 wherein the processor further identifies a registration break in the closed loop, the registration break being between two consecutive frames i and i+1 in the sequence; assigns all registration errors in the closed loop to a pair-wise registration between frames i and i+1; and updates pair-wise transformation parameters according to a transformation matrix for frames i and i+1.
 23. One or more tangible, non-transitory computer-readable media as in claim 17 wherein the processor further marks all pair-wise registrations of image frames within the closed loop as fixed.
 24. One or more tangible, non-transitory computer-readable media as in claim 23 wherein the registration parameters of pair-wise registrations of image frames within the closed loop that have been marked as fixed are not adjusted during the global optimization. 